*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* Trawalter 2011 TESS Survey Experiment
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data available here: http://www.tessexperiments.org/data/trawalter210.html
*******************************************************************************************************************************
*******************************************************************************************************************************

* use "TESS2_089_Trawalter_Client.dta", clear
set more off

*******************************************************************************************************************************
*** Racial groups
*******************************************************************************************************************************

tab PPETHM
gen whiteR = PPETHM
recode whiteR (2/4=0)
tab PPETHM whiteR
gen blackR = PPETHM
recode blackR (1 3 4=0) (2=1)
tab PPETHM blackR
gen hispnR = PPETHM
recode hispnR (1/3=0) (4=1)
tab PPETHM hispnR

*******************************************************************************************************************************
*** Treatments
*******************************************************************************************************************************

tab XTESS089
gen Twhite = 0
gen Tblack = 0
gen Thispanic = 0
gen Tasian = 0
replace Twhite = 1 if mod(Image_Shown,4) == 1
replace Tblack = 1 if mod(Image_Shown,4) == 2
replace Thispanic = 1 if mod(Image_Shown,4) == 3
replace Tasian = 1 if mod(Image_Shown,4) == 0

tab XTESS089 Twhite
tab XTESS089 Tblack
tab XTESS089 Thispanic
tab XTESS089 Tasian
gen Tmale = 0
gen Tfemale = 0
replace Tmale = 1 if XTESS089 < 12
replace Tfemale = 1 if XTESS089 >= 12
tab XTESS089 Tmale
tab XTESS089 Tfemale

*******************************************************************************************************************************
*** Outcome variables
*******************************************************************************************************************************

tab1 Q1-Q10
recode Q1-Q10 (-1=.)

alpha Q1 Q2 Q3 Q4, min(2) std item gen(painME)

sum painME if whiteR==1
di r(sd)
gen painME_white_std = painME/r(sd) if whiteR==1

sum painME if blackR==1
di r(sd)
gen painME_black_std = painME/r(sd) if blackR==1

sum painME if hispnR==1
di r(sd)
gen painME_hispn_std = painME/r(sd) if hispnR==1

alpha Q5 Q6 Q7 Q8, min(2) std item gen(painTHEM)

sum painTHEM if whiteR==1
di r(sd)
gen painTHEM_white_std = painTHEM/r(sd) if whiteR==1

sum painTHEM if blackR==1
di r(sd)
gen painTHEM_black_std = painTHEM/r(sd) if blackR==1

sum painTHEM if hispnR==1
di r(sd)
gen painTHEM_hispn_std = painTHEM/r(sd) if hispnR==1

*******************************************************************************************************************************
*** Racial manipulation check
*******************************************************************************************************************************

// No racial manipulation check

*******************************************************************************************************************************
*** Main regressions [Unweighted]
*******************************************************************************************************************************

reg painTHEM_white_std Tblack Thispanic Tasian Tmale painME_white_std if (Tblack==1 | Twhite==1) & whiteR==1
reg painTHEM_black_std Tblack Thispanic Tasian Tmale painME_black_std if (Tblack==1 | Twhite==1) & blackR==1
reg painTHEM_hispn_std Tblack Thispanic Tasian Tmale painME_hispn_std if (Tblack==1 | Twhite==1) & hispnR==1
